package com.atguigu.springboot.springbootkafka.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试：
 *      1、运行 KafkaConsumer.java
 *      2、运行 ProducerController.java
 *      3、浏览器运行：
 *          localhost:8080/atguigu?msg="atguigu"
 *      4、查看 KafkaConsumer.java 控制台输出
 */
@RestController
public class ProducerController {

    @Autowired
    KafkaTemplate<String, String> kafka;

    @RequestMapping("/atguigu")
    public String data(String msg) {
        // 通过kafka发送出去
        kafka.send("first", msg);

        return "ok";
    }
}
